<template>
  <view class="content">

    <view v-if="dataList.length  != 0">

      <view v-for="(item,index) in dataList" :key="index" @click="jump_page(item,index)">
        <!-- {{ item.name  }} -->
        <!-- 主体 -->
        <view class="head_body">
          <view class="img_view">
            <img :src=" IMG_URL + item.thumb" alt="">
          </view>
          <view :class="item.states == 1 ? 'flort1': item.states == 2 ?'flort' : item.states == 3 ?'flort2':''  ">
            {{ item.states == 3 ? '报名已结束': item.states == 2 ?'报名进行中' : item.states == 1 ?'报名未开始':''   }}
          </view>
          <!-- <view :class="item.state == 1 ? 'flort': item.state == 2 ?'flort1' : item.state == 3 ?'flort2':''  ">
            {{ item.state == 1 ? '报名进行中': item.state == 2 ?'报名已结束' : item.state == 3 ?'报名未开始':''   }}
          </view> -->
          <view class="name">
            {{ item.activityName }}
          </view>
          <view class="dataTime">
            {{ item.activityStartDate }} / {{ item.activityEndDate }}
          </view>
        </view>
      </view>
    </view>
    <view v-else class="dis_none">
      暂时没有数据
    </view> 

  </view>
</template>

<script>
  import {
    IMG_URL
  } from "../../env.js"
  import {
    getActivityListByGroupId
  } from '@/common/request/api.js'
  export default {
    data() {
      return {
        IMG_URL,
        ids: "",
        title: 'Hello',
        dataList: []
      }
    },
    onLoad(options) {
      this.ids = options.id
      this.getActivityListByGroupId(this.ids)
    },
    methods: {
      jump_page(a, b) {
        console.log(a, b);
        console.log(uni.navigateTo());
        uni.navigateTo({
          url: '../ActivityDetail/index?id=' + a.id
        });
      },
      getActivityListByGroupId(id) {
        uni.showLoading({
          title: '加载中',
          mask: true
        })
        getActivityListByGroupId(id).then(res => {
          console.log(res)
          if (res.data.code == 200) {
            this.dataList = res.data.data
            uni.hideLoading()
          } else {
            uni.showToast({
              title: res.data.msg,
              icon: 'none',
              duration: 2000
            })
            uni.hideLoading()
          }
        })
      }
    }
  }
</script>

<style lang="less" scoped src="./index.less">


</style>